package compsoft;

import org.apache.catalina.Context;
import org.apache.catalina.Engine;
import org.apache.catalina.Host;
import org.apache.catalina.realm.MemoryRealm;
import org.apache.catalina.startup.Embedded;
import org.apache.catalina.connector.*;

public class Main{

public static void main(String[] args){ 
	Embedded embeddedTomcat = new Embedded(); 
	MemoryRealm memRealm = new MemoryRealm(); 
	embeddedTomcat.setRealm(memRealm);

	Engine engine = embeddedTomcat.createEngine();

	Host host = embeddedTomcat.createHost("localhost", "/webapps");	
	engine.addChild(host);	
	Context rootCtx = embeddedTomcat.createContext("/", "/compsoft"); 
	rootCtx.setPrivileged(true); 
	host.addChild(rootCtx); 
	embeddedTomcat.addEngine(engine);

	Connector httpConnector = embeddedTomcat.createConnector((java.net.InetAddress) null, 8080, false);

	embeddedTomcat.addConnector(httpConnector);
	try{ 		
		embeddedTomcat.start(); 
	} catch (org.apache.catalina.LifecycleException ex){ 
		System.out.println("Startup failed"); 
		System.out.println(ex.getMessage()); 
		} 
	} 
}
